﻿<%@  Language="C#" MasterPageFile="~/Masters/Basic.Master" AutoEventWireup="true" CodeBehind="BottleDelivery.aspx.cs" Inherits="PMS.UI.CM.BottleDelivery" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(function () {
            var height = $("#divTotal").height();
            var master = $("#master").height();
            var content = parseFloat(height) - parseFloat(master) - 30;
            $("#tbList").css("height", content);
        });
    </script>
    <script type="text/javascript">
        $(function () {
            //   $('#btnModify').linkbutton('disable');
            $("#tbList").datagrid({
                url: '/Logic/CM/BottleDeliveryAjax.aspx?method=GetBottleDeliveryList',
                loadMsg: '数据加载中请稍后……',
                fitColumns: false,
                pagination: true,
                queryParams: com.serializeSearchArray("form1"),
                rownumbers: true,
                idField: "ID",
                singleSelect: false,
                pageSize: 20,
                pageList: [20, 50, 100],
                striped: true,
                frozenColumns: [[{ field: 'ck', checkbox: true, width: 30 },
                 //{ field: 'ID', title: 'ID', align: "center", width: 40 },
                 { field: 'ProductOrderCode', title: '生产订单号 ', align: "center", width: 100 },
                 { field: 'ContractCode', title: '合同编号', align: "center", width: 100 },
                 { field: 'CustomerName', title: '客户单位名称', align: "center", width: 100 },
                 { field: 'OrderDate', title: '下单日期', align: "center", width: 80, sortable: true },
                 { field: 'ReleaseDate', title: '交货日期', align: "center", width: 80, sortable: true },
                ]],
                columns: [[

                     { field: 'SerialCode', title: '配气流水号', align: "center", width: 100 },
                     {
                         field: 'State', title: '气瓶状态', align: "center", width: 60,
                         formatter: function (value, row, Index) {
                             return com.getArrayText(StaticCombo.BottleState, value);
                         }
                     },
                 { field: 'BottleCode', title: '气瓶编号', align: "center", width: 100 },
                 { field: 'BottleVolume', title: '气瓶容积（L）', align: "center", width: 60 },
                  { field: 'CommissionDate', title: '投产日期', align: "center", width: 120, sortable: true },
                  { field: 'CompletedDate', title: '配气完成日期', align: "center", width: 120, sortable: true },
                  { field: 'AnalyseDate', title: '分析日期', align: "center", width: 120, sortable: true },
                  {
                      field: 'AnalyseRes', title: '分析结果', align: "center", width: 60,
                      formatter: function (value, row, index) {
                          return com.getArrayText(StaticCombo.BottleAnalyseRes, value)
                      }
                  },
                   { field: 'Note', title: '备注', align: "center", width: 60, sortable: true },
                   { field: 'ProductName', title: '产品名称', align: "center", width: 100 },
                    { field: 'OrderCount', title: '产品订货数', align: "center", width: 100 },
                  {
                      field: 'TechParams', title: '技术参数', align: "center", width: 200,
                      formatter: function (value, row, index) {
                          //鼠标放在文本处自动显示tooltip
                          return '<span title=' + value + '>' + value + '</span>';
                          //文本超出列宽自动换行
                         // return '<div style="width=100px;word-break:break-all; word-wrap:break-word;white-space:pre-wrap;">' + value + '</div>';
                      }
                  },
                { field: 'ReceiveAddress', title: '送货地址', align: "center", width: 100 },
                { field: 'InvoiceAddress', title: '收发票地址', align: "center", width: 100 }
                ]],
                onDblClickRow: function (rowIndex, rowData) {

                },
                onLoadSuccess: function (data) {
                    com.mergeCells("tbList", "ProductOrderCode,ContractCode, CustomerName, " +
                       "OrderDate,ReleaseDate,ReceiveAddress,InvoiceAddress")
                }
            });

        });

    </script>

    <script type="text/javascript">
        //查询
        function funcSearch() {
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
        }

        //重置
        function funcReload() {
            $("#form1").form("reset");
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
        }

        //发货
        function funcDeliver() {
            var rows = $('#tbList').datagrid('getSelections');
            if (rows.length == 0) {
                com.message("information", "请选中一行");
                return
            }
            var oId = { deliveryInfo: JSON.stringify(rows) };
            for (var j = 0; j < rows.length; j++) {
                if (rows[0].CustomerName != rows[j].CustomerName) {
                    com.message("error", "存在不一样的客户，请重新选择");
                    return;
                }
                if (rows[0].ProductOrderCode != rows[j].ProductOrderCode) {
                    com.message("error", "存在不一样的生产订单，请重新选择");
                    return;
                }
                if (rows[j].State == '0') {
                    com.message("error", "存在还未配气完成的气瓶，请重新选择");
                    return;
                }
                if (rows[j].State == '1') {
                    com.message("error", "存在还未分析完成的气瓶，请重新选择");
                    return;
                }
                if (rows[j].State == '2') {
                    com.message("error", "存在还未入库的气瓶，请重新选择");
                    return;
                }
                if (rows[j].State == '4') {
                    com.message("error", "存在已经发货的气瓶，请重新选择");
                    return;
                }
            }
            com.ajax({
                url: "/Logic/CM/BottleDeliveryAjax.aspx?method=AddDelivery",
                data: oId,
                success: function (data) {
                    if (data.state == "success") {
                        top.wrapper.addTab("气瓶发货细则", "/UI/CM/BottleDeliveryDetail.aspx?action=add&ID=" + data.deliveryID)
                    }
                }
            });
        }
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">

        <div id="master" class="container_16" style="height: auto">
            <form id="form1">
                <div class="grid_2 sealbl" style="width: 100px">
                    生产订单号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="ProductOrderCode" name="ProductOrderCode" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    客户名称 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="CustomerName" name="CustomerName" data-cp="=" data-options="valueField:'text',textField:'text',url:'/Logic/BD/CompanyAjax.aspx?method=GetAllCompanyNameList',panelHeight:'auto'" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    合同编号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="ContractCode" name="ContractCode" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    气瓶状态 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="State" name="State" data-cp="=" data-options="valueField:'value',textField:'text',data:StaticCombo.BottleStateQuery,panelHeight:'auto'"/>
                </div>

                <div class="Clear"></div>
                <div class="grid_2 sealbl" style="width: 100px">
                    下单日期从:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="startOrderDate" name="startOrderDate" data-cp="str>=" class="easyui-datebox" />
                </div>
                <div class="grid_2 sealbl">
                    到:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="endOrderDate" name="endOrderDate" data-cp="str<=" class="easyui-datebox" />
                </div>
                <div class="grid_2 sealbl" style="width: 100px">
                    交货日期从:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="startReleaseDate" name="startReleaseDate" data-cp="str>=" class="easyui-datebox" />
                </div>
                <div class="grid_2 sealbl">
                    到:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="endReleaseDate" name="endReleaseDate" data-cp="str<=" class="easyui-datebox" />
                </div>
            </form>
        </div>
        <table id="tbList" title="气瓶发货信息表 " style="width: 100%">
        </table>
    </div>
</asp:Content>
